<?php

namespace App\Listeners;

use App\Events\PostSaved;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

//引入日志和缓存
// use Cache;
// use Log;
use DB;

class SaveDataToCache
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  PostSaved  $event
     * @return void
     */
    public function handle(PostSaved $event)
    {
        $action = $event -> action;

        // $ass = [
        //     'action_name' => $action -> action_name,
        //     'action_time' => $action -> action_time,
        //     'action_biao' => $action -> action_biao,
        //     'action_project' => $action -> action_project,
        //     'admin_id'    => $action -> admin_id  
        // ];

        DB::table("action") -> insert([
            'action_name' => $action -> action_name,
            'action_time' => $action -> action_time,
            // 'action_time' => date('Y-m-d H:s:i'),
            'action_biao' => $action -> action_biao,
            'action_project' => $action -> action_project,
            'admin_id'    => $action -> admin_id  
        ]);
    }
}
